package cn.com.roy.thread.t4_1_9.fairnofairtest;

import java.util.concurrent.locks.ReentrantLock;

public class MyService {
    private ReentrantLock lock;
    public MyService(boolean fair){
        this.lock = new ReentrantLock(fair);
    }

    public void testMethod(){
        try {
            lock.lock();
            System.out.println("ThreadName = " + Thread.currentThread().getName() + "获得锁定") ;
        } finally {
            lock.unlock();
        }

    }
}
